﻿@{
    SiteSecurity.RequireAuthenticatedUser();

    Page.Title = "Disassociate OAuth accounts";
    Layout = "~/Shared/_SiteLayout.cshtml";

    IList<WebMatrix.WebData.OAuthAccountData> accounts = null;

    if (IsPost)
    {
        string provider = Request.Form["provider"];
        string providerUserId = Request.Form["providerUserId"];
        AuthWebSecurity.DeleteAccount(provider, providerUserId);
    }

    //string username =SiteSecurity.CurrentUserName;
    // accounts = AuthWebSecurity.GetAccountsForUser(username);
    //accounts = AuthWebSecurity.GetAccountsForUser();

}
<hgroup class="title">
    <h1>Disassociate.</h1>
    <h2>Choose a service to disassociate with this account.</h2>
</hgroup>
@if (accounts != null && accounts.Count> 0)
{

    <fieldset>
        <legend>Choose a service to disassociate with this account</legend>
        @foreach (var service in accounts)
        {
            <form action="" method="post">
            <input type="hidden" name="providerUserId" value="@service.ProviderUserId" />
            <input type="submit" name="provider" id="@service.Provider" value="@service.Provider" title="Disassociate @(service.Provider + " - " + service.ProviderUserId) from this account." />
            </form>
        }
    </fieldset>

}
else
{
    <div class="message-info">
        <p>
            This account is not associated with any additional services.</p>
    </div>
}